﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Sgr.Security.Tokens.Services
{
    public interface ITemporaryTokenService
    {
        /// <summary>
        /// 创建一个新的临时令牌
        /// </summary>
        /// <param name="tokenType">令牌类型</param>
        /// <param name="expirationMinutes">过期时间(分钟) [ 默认5分钟] </param>
        /// <param name="content">令牌内容</param>
        /// <param name="deviceFingerprint">关联的设备指纹 [ 默认无] </param>
        /// <param name="userId">关联的用户标识 [ 默认无] </param>
        /// <param name="cancellationToken"> </param>
        /// <returns></returns>
        Task<TemporaryToken> CreateAsync(int tokenType,
            int expirationMinutes = 5,
            string? content = null,
            string? deviceFingerprint = null,
            string? userId = null,
            CancellationToken cancellationToken = default);

        /// <summary>
        /// 验证临时令牌
        /// </summary>
        /// <param name="code"></param>
        /// <param name="tokenType"></param>
        /// <param name="content"></param>
        /// <param name="deviceFingerprint"></param>
        /// <param name="userId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<bool> ValidateAsync(string code,
            int tokenType,
            string? content = null,
            string? deviceFingerprint = null,
            string? userId = null,
            CancellationToken cancellationToken = default);
    }
}